package com.blog.backend.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Component
public class WebConfig implements WebMvcConfigurer {

    @Resource
    GlobalInterceptor globalInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(globalInterceptor);
        //静态文件html格式不拦截
        interceptorRegistration.excludePathPatterns(                         //添加不拦截路径
                "/**/*.html",
                "/**/*.css",
                "/**/*.js"
        );
    }
}
